package com.wrench.elevator.tida.service;

import com.wrench.elevator.tida.constant.Result;
import com.wrench.elevator.tida.dao.BuildingDao;
import com.wrench.elevator.tida.domain.Page;
import com.wrench.elevator.tida.exception.WrenchException;
import com.wrench.elevator.tida.util.WrenchUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Component
public class BuildingService {
    @Resource
    private BuildingDao dao;

    private static final Logger logger = LoggerFactory.getLogger(BuildingService.class);


    public  Page queryDanyuanByBuildingName(String buildingName, String wuye_id,String current_page,String limit) throws WrenchException {
        if (WrenchUtil.hasNull(buildingName, wuye_id,current_page, limit)) {
            logger.error("==> param is not found , buildingName = {} , wuye_id = {} , current_page = {} , limit = {} ",
                    buildingName,
                    wuye_id,
                    current_page,
                    limit);
            throw new WrenchException(Result.PARAM_IS_NOT_FOUND_CODE, Result.PARAM_IS_NOT_FOUND_MESSAGE);
        }

        if (!WrenchUtil.areInt(current_page, limit)) {
            logger.error("==> string is not int type , current_apge = {} , limit = {} ", current_page, limit);
            throw new WrenchException(Result.STRING_IS_NOT_INT_TYPE_MESSAGE, Result.STRING_IS_NOT_INT_TYPE_MESSAGE);
        }
        int int_current_page=Integer.valueOf(current_page);
        int int_limit=Integer.valueOf(limit);
        List<Map<String,String>> list=null;
        try {
            list=dao.queryDanyuanByBuildingName(buildingName,wuye_id,(int_current_page-1)*int_limit,int_limit);
        } catch (Exception e) {
            logger.error("==> data=dao.queryDanyuanByBuildingName(province_id,wuye_id,(int_current_page-1)*int_limit,int_limit) execute error , buildingName = {} , wuye_id = {} , current_page = {} , limit = {} , error = {} ",buildingName,wuye_id,current_page,limit,e);
            throw new WrenchException(Result.DB_ERROR_CODE,Result.DB_ERROR_MESSAGE);
        }
        int total=-1;
        try {
            total=dao.queryDanyuanByBuildingNameCount(buildingName,wuye_id);
        } catch (Exception e) {
            logger.error("==> total=dao.queryDanyuanByBuildingNameCount(buildingName,wuye_id) execute error , buildingName = {} , wuye_id = {} , error = {} ",buildingName,wuye_id,e);
            throw new WrenchException(Result.DB_ERROR_CODE,Result.DB_ERROR_MESSAGE);
        }
        Page page=new Page();
        page.setCurrent_page(int_current_page);
        page.setLimit(int_limit);
        page.setList(list);
        page.setTotal(total);
        return page;

    }

   public  Page queryDanyuanByProvinceId(String province_id, String wuye_id,String current_page,String limit) throws WrenchException {
       if (WrenchUtil.hasNull(province_id, wuye_id,current_page, limit)) {
           logger.error("==> param is not found , province_id = {} , wuye_id = {} , current_page = {} , limit = {} ",
                   province_id,
                   wuye_id,
                   current_page,
                   limit);
           throw new WrenchException(Result.PARAM_IS_NOT_FOUND_CODE, Result.PARAM_IS_NOT_FOUND_MESSAGE);
       }

       if (!WrenchUtil.areInt(current_page, limit)) {
           logger.error("==> string is not int type , current_apge = {} , limit = {} ", current_page, limit);
           throw new WrenchException(Result.STRING_IS_NOT_INT_TYPE_MESSAGE, Result.STRING_IS_NOT_INT_TYPE_MESSAGE);
       }
       int int_current_page=Integer.valueOf(current_page);
       int int_limit=Integer.valueOf(limit);
       List<Map<String,String>> list=null;
       try {
           list=dao.queryDanyuanByProvinceId(province_id,wuye_id,(int_current_page-1)*int_limit,int_limit);
       } catch (Exception e) {
           logger.error("==> data=dao.queryDanyuanByProvinceId(province_id,wuye_id,(int_current_page-1)*int_limit,int_limit) execute error , province_id = {} , wuye_id = {} , current_page = {} , limit = {} , error = {} ",province_id,wuye_id,current_page,limit,e);
           throw new WrenchException(Result.DB_ERROR_CODE,Result.DB_ERROR_MESSAGE);
       }
       int total=-1;
       try {
           total=dao.queryDanyuanByProvinceIdCount(province_id,wuye_id);
       } catch (Exception e) {
           logger.error("==> total=dao.queryDanyuanByProvinceIdCount(province_id,wuye_id) execute error , province_id = {} , wuye_id = {} , error = {} ",province_id,wuye_id,e);
           throw new WrenchException(Result.DB_ERROR_CODE,Result.DB_ERROR_MESSAGE);
       }
       Page page=new Page();
       page.setCurrent_page(int_current_page);
       page.setLimit(int_limit);
       page.setList(list);
       page.setTotal(total);
       return page;

   }

   public Page queryDanyuanByCityId(String city_id,String wuye_id,String current_page,String limit) throws WrenchException {
       if (WrenchUtil.hasNull(city_id, wuye_id,current_page, limit)) {
           logger.error("==> param is not found , city_id = {} , wuye_id = {} , current_page = {} , limit = {} ",
                   city_id,
                   wuye_id,
                   current_page,
                   limit);
           throw new WrenchException(Result.PARAM_IS_NOT_FOUND_CODE, Result.PARAM_IS_NOT_FOUND_MESSAGE);
       }

       if (!WrenchUtil.areInt(current_page, limit)) {
           logger.error("==> string is not int type , current_apge = {} , limit = {} ", current_page, limit);
           throw new WrenchException(Result.STRING_IS_NOT_INT_TYPE_MESSAGE, Result.STRING_IS_NOT_INT_TYPE_MESSAGE);
       }

       int int_current_page=Integer.valueOf(current_page);
       int int_limit=Integer.valueOf(limit);
       List<Map<String,String>> list=null;

       try {
           list=dao.queryDanyuanByCityId(city_id,wuye_id,(int_current_page-1)*int_limit,int_limit);
       } catch (Exception e) {
          logger.error("==> list=dao.queryDanyuanByCityId(city_id,wuye_id,(int_current_page-1)*int_limit,int_limit) execute error , city_id = {} , wuye_id = {} , current_page = {} , limit = {} , error = {} ",city_id,wuye_id,current_page,limit,e);
          throw new WrenchException(Result.DB_ERROR_CODE,Result.DB_ERROR_MESSAGE);
       }
       int total =-1;
       try {
           total=dao.queryDanyuanByCityIdCount(city_id,wuye_id);
       } catch (Exception e) {
           logger.error("==> total=dao.queryDanyuanByCityIdCount(city_id,wuye_id) execute error , city_id = {} , wuye_id = {} , error = {} ",city_id,wuye_id,e);
           throw new WrenchException(Result.DB_ERROR_CODE,Result.DB_ERROR_MESSAGE);
       }

       Page page=new Page();
       page.setCurrent_page(int_current_page);
       page.setLimit(int_limit);
       page.setList(list);
       page.setTotal(total);
       return page;

   }

   public Page queryDanyuanByDistrictId(String district_id,String wuye_id,String current_page,String limit) throws WrenchException {
       if (WrenchUtil.hasNull(district_id, wuye_id,current_page, limit)) {
           logger.error("==> param is not found , district_id = {} , wuye_id = {} , current_page = {} , limit = {} ",
                   district_id,
                   wuye_id,
                   current_page,
                   limit);
           throw new WrenchException(Result.PARAM_IS_NOT_FOUND_CODE, Result.PARAM_IS_NOT_FOUND_MESSAGE);
       }

       if (!WrenchUtil.areInt(current_page, limit)) {
           logger.error("==> string is not int type , current_apge = {} , limit = {} ", current_page, limit);
           throw new WrenchException(Result.STRING_IS_NOT_INT_TYPE_MESSAGE, Result.STRING_IS_NOT_INT_TYPE_MESSAGE);
       }
       int int_current_page=Integer.valueOf(current_page);
       int int_limit=Integer.valueOf(limit);
       List<Map<String,String>> list=null;

       try {
           list=dao.queryDanyuanByDistrictId(district_id,wuye_id,(int_current_page-1)*int_limit,int_limit);
       } catch (Exception e) {
           logger.error("==> list=dao.queryDanyuanByDistrictId(district_id,wuye_id,(int_current_page-1)*int_limit,int_limit) execute error , city_id = {} , wuye_id = {} , current_page = {} , limit = {} , error = {} ",district_id,wuye_id,current_page,limit,e);
           throw new WrenchException(Result.DB_ERROR_CODE,Result.DB_ERROR_MESSAGE);
       }
       int total =-1;
       try {
           total=dao.queryDanyuanByDistrictIdCount(district_id,wuye_id);
       } catch (Exception e) {
           logger.error("==> total=dao.queryDanyuanByDistrictIdCount(district_id,wuye_id) execute error , district_id = {} , wuye_id = {} , error = {} ",district_id,wuye_id,e);
           throw new WrenchException(Result.DB_ERROR_CODE,Result.DB_ERROR_MESSAGE);
       }

       Page page=new Page();
       page.setCurrent_page(int_current_page);
       page.setLimit(int_limit);
       page.setList(list);
       page.setTotal(total);
       return page;

   }

  public Page queryDanyuanByBuildingId(String building_id,String current_page,String limit) throws WrenchException {
      if (WrenchUtil.hasNull(building_id,current_page, limit)) {
          logger.error("==> param is not found , building_id = {} , current_page = {} , limit = {} ",
                  building_id,
                  current_page,
                  limit);
          throw new WrenchException(Result.PARAM_IS_NOT_FOUND_CODE, Result.PARAM_IS_NOT_FOUND_MESSAGE);
      }

      if (!WrenchUtil.areInt(current_page, limit)) {
          logger.error("==> string is not int type , current_apge = {} , limit = {} ", current_page, limit);
          throw new WrenchException(Result.STRING_IS_NOT_INT_TYPE_MESSAGE, Result.STRING_IS_NOT_INT_TYPE_MESSAGE);
      }
      int int_current_page=Integer.valueOf(current_page);
      int int_limit=Integer.valueOf(limit);
      List<Map<String,String>> list=null;

      try {
          list=dao.queryDanyuanByBuildingId(building_id,(int_current_page-1)*int_limit,int_limit);
      } catch (Exception e) {
          logger.error("==> list=dao.queryDanyuanByBuildingId(building_id,(int_current_page-1)*int_limit,int_limit) execute error , building_id = {} , current_page = {} , limit = {} , error = {} ",building_id,current_page,limit,e);
          throw new WrenchException(Result.DB_ERROR_CODE,Result.DB_ERROR_MESSAGE);
      }
      int total =-1;
      try {
          total=dao.queryDanyuanByBuildingIdCount(building_id);
      } catch (Exception e) {
          logger.error("==> total=dao.queryDanyuanByBuildingIdCount(building_id) execute error , building_id = {} , error = {} ",building_id,e);
          throw new WrenchException(Result.DB_ERROR_CODE,Result.DB_ERROR_MESSAGE);
      }

      Page page=new Page();
      page.setCurrent_page(int_current_page);
      page.setLimit(int_limit);
      page.setList(list);
      page.setTotal(total);
      return page;
  }

   public Page queryDanyuanByDanyuanId(String danyuan_id, String current_page, String limit) throws WrenchException {
       if (WrenchUtil.hasNull(danyuan_id,current_page, limit)) {
           logger.error("==> param is not found , danyuan_id = {} , current_page = {} , limit = {} ",
                   danyuan_id,
                   current_page,
                   limit);
           throw new WrenchException(Result.PARAM_IS_NOT_FOUND_CODE, Result.PARAM_IS_NOT_FOUND_MESSAGE);
       }

       if (!WrenchUtil.areInt(current_page, limit)) {
           logger.error("==> string is not int type , current_apge = {} , limit = {} ", current_page, limit);
           throw new WrenchException(Result.STRING_IS_NOT_INT_TYPE_MESSAGE, Result.STRING_IS_NOT_INT_TYPE_MESSAGE);
       }
       int int_current_page=Integer.valueOf(current_page);
       int int_limit=Integer.valueOf(limit);
       List<Map<String,String>> list=null;

       try {
           list=dao.queryDanyuanByDanyuanId(danyuan_id,(int_current_page-1)*int_limit,int_limit);
       } catch (Exception e) {
           logger.error("==> list=dao.queryDanyuanByDanyuanId(danyuan_id,(int_current_page-1)*int_limit,int_limit) execute error , danyuan_id= {} , current_page = {} , limit = {} , error = {} ",danyuan_id,current_page,limit,e);
           throw new WrenchException(Result.DB_ERROR_CODE,Result.DB_ERROR_MESSAGE);
       }
       int total =-1;
       try {
           total=dao.queryDanyuanByDanyuanIdCount(danyuan_id);
       } catch (Exception e) {
           logger.error("==>  total=dao.queryDanyuanByDanyuanIdCount(danyuan_id) execute error , danyuan_id = {} , wuye_id = {} , error = {} ",danyuan_id,e);
           throw new WrenchException(Result.DB_ERROR_CODE,Result.DB_ERROR_MESSAGE);
       }

       Page page=new Page();
       page.setCurrent_page(int_current_page);
       page.setLimit(int_limit);
       page.setList(list);
       page.setTotal(total);
       return page;
   }



    public  Page queryChengtiComplainByProvinceId(String province_id, String wuye_id,String current_page,String limit) throws WrenchException {
        if (WrenchUtil.hasNull(province_id, wuye_id,current_page, limit)) {
            logger.error("==> param is not found , province_id = {} , wuye_id = {} , current_page = {} , limit = {} ",
                    province_id,
                    wuye_id,
                    current_page,
                    limit);
            throw new WrenchException(Result.PARAM_IS_NOT_FOUND_CODE, Result.PARAM_IS_NOT_FOUND_MESSAGE);
        }

        if (!WrenchUtil.areInt(current_page, limit)) {
            logger.error("==> string is not int type , current_apge = {} , limit = {} ", current_page, limit);
            throw new WrenchException(Result.STRING_IS_NOT_INT_TYPE_MESSAGE, Result.STRING_IS_NOT_INT_TYPE_MESSAGE);
        }
        int int_current_page=Integer.valueOf(current_page);
        int int_limit=Integer.valueOf(limit);
        List<Map<String,String>> list=null;
        try {
            list=dao.queryChengtiComplainByProvinceId(province_id,wuye_id,(int_current_page-1)*int_limit,int_limit);
        } catch (Exception e) {
            logger.error("==> data=dao.queryChengtiComplainByProvinceId(province_id,wuye_id,(int_current_page-1)*int_limit,int_limit) execute error , province_id = {} , wuye_id = {} , current_page = {} , limit = {} , error = {} ",province_id,wuye_id,current_page,limit,e);
            throw new WrenchException(Result.DB_ERROR_CODE,Result.DB_ERROR_MESSAGE);
        }
        int total=-1;
        try {
            total=dao.queryChengtiComplainByProvinceIdCount(province_id,wuye_id);
        } catch (Exception e) {
            logger.error("==> total=dao.queryChengtiComplainByProvinceIdCount(province_id,wuye_id) execute error , province_id = {} , wuye_id = {} , error = {} ",province_id,wuye_id,e);
            throw new WrenchException(Result.DB_ERROR_CODE,Result.DB_ERROR_MESSAGE);
        }
        Page page=new Page();
        page.setCurrent_page(int_current_page);
        page.setLimit(int_limit);
        page.setList(list);
        page.setTotal(total);
        return page;

    }

    public Page queryChengtiComplainByCityId(String city_id,String wuye_id,String current_page,String limit) throws WrenchException {
        if (WrenchUtil.hasNull(city_id, wuye_id,current_page, limit)) {
            logger.error("==> param is not found , city_id = {} , wuye_id = {} , current_page = {} , limit = {} ",
                    city_id,
                    wuye_id,
                    current_page,
                    limit);
            throw new WrenchException(Result.PARAM_IS_NOT_FOUND_CODE, Result.PARAM_IS_NOT_FOUND_MESSAGE);
        }

        if (!WrenchUtil.areInt(current_page, limit)) {
            logger.error("==> string is not int type , current_apge = {} , limit = {} ", current_page, limit);
            throw new WrenchException(Result.STRING_IS_NOT_INT_TYPE_MESSAGE, Result.STRING_IS_NOT_INT_TYPE_MESSAGE);
        }

        int int_current_page=Integer.valueOf(current_page);
        int int_limit=Integer.valueOf(limit);
        List<Map<String,String>> list=null;

        try {
            list=dao.queryChengtiComplainByCityId(city_id,wuye_id,(int_current_page-1)*int_limit,int_limit);
        } catch (Exception e) {
            logger.error("==> list=dao.queryChengtiComplainByCityId(city_id,wuye_id,(int_current_page-1)*int_limit,int_limit) execute error , city_id = {} , wuye_id = {} , current_page = {} , limit = {} , error = {} ",city_id,wuye_id,current_page,limit,e);
            throw new WrenchException(Result.DB_ERROR_CODE,Result.DB_ERROR_MESSAGE);
        }
        int total =-1;
        try {
            total=dao.queryChengtiComplainByCityIdCount(city_id,wuye_id);
        } catch (Exception e) {
            logger.error("==> total=dao.queryChengtiComplainByCityIdCount(city_id,wuye_id) execute error , city_id = {} , wuye_id = {} , error = {} ",city_id,wuye_id,e);
            throw new WrenchException(Result.DB_ERROR_CODE,Result.DB_ERROR_MESSAGE);
        }

        Page page=new Page();
        page.setCurrent_page(int_current_page);
        page.setLimit(int_limit);
        page.setList(list);
        page.setTotal(total);
        return page;

    }

    public Page queryChengtiComplainByDistrictId(String district_id,String wuye_id,String current_page,String limit) throws WrenchException {
        if (WrenchUtil.hasNull(district_id, wuye_id,current_page, limit)) {
            logger.error("==> param is not found , district_id = {} , wuye_id = {} , current_page = {} , limit = {} ",
                    district_id,
                    wuye_id,
                    current_page,
                    limit);
            throw new WrenchException(Result.PARAM_IS_NOT_FOUND_CODE, Result.PARAM_IS_NOT_FOUND_MESSAGE);
        }

        if (!WrenchUtil.areInt(current_page, limit)) {
            logger.error("==> string is not int type , current_apge = {} , limit = {} ", current_page, limit);
            throw new WrenchException(Result.STRING_IS_NOT_INT_TYPE_MESSAGE, Result.STRING_IS_NOT_INT_TYPE_MESSAGE);
        }
        int int_current_page=Integer.valueOf(current_page);
        int int_limit=Integer.valueOf(limit);
        List<Map<String,String>> list=null;

        try {
            list=dao.queryChengtiComplainByDistrictId(district_id,wuye_id,(int_current_page-1)*int_limit,int_limit);
        } catch (Exception e) {
            logger.error("==> list=dao.queryChengtiComplainByDistrictId(district_id,wuye_id,(int_current_page-1)*int_limit,int_limit) execute error , city_id = {} , wuye_id = {} , current_page = {} , limit = {} , error = {} ",district_id,wuye_id,current_page,limit,e);
            throw new WrenchException(Result.DB_ERROR_CODE,Result.DB_ERROR_MESSAGE);
        }
        int total =-1;
        try {
            total=dao.queryChengtiComplainByDistrictIdCount(district_id,wuye_id);
        } catch (Exception e) {
            logger.error("==> total=dao.queryChengtiComplainByDistrictIdCount(district_id,wuye_id) execute error , district_id = {} , wuye_id = {} , error = {} ",district_id,wuye_id,e);
            throw new WrenchException(Result.DB_ERROR_CODE,Result.DB_ERROR_MESSAGE);
        }

        Page page=new Page();
        page.setCurrent_page(int_current_page);
        page.setLimit(int_limit);
        page.setList(list);
        page.setTotal(total);
        return page;

    }

    public Page queryChengtiComplainByBuildingId(String building_id,String current_page,String limit) throws WrenchException {
        if (WrenchUtil.hasNull(building_id,current_page, limit)) {
            logger.error("==> param is not found , building_id = {} , current_page = {} , limit = {} ",
                    building_id,
                    current_page,
                    limit);
            throw new WrenchException(Result.PARAM_IS_NOT_FOUND_CODE, Result.PARAM_IS_NOT_FOUND_MESSAGE);
        }

        if (!WrenchUtil.areInt(current_page, limit)) {
            logger.error("==> string is not int type , current_apge = {} , limit = {} ", current_page, limit);
            throw new WrenchException(Result.STRING_IS_NOT_INT_TYPE_MESSAGE, Result.STRING_IS_NOT_INT_TYPE_MESSAGE);
        }
        int int_current_page=Integer.valueOf(current_page);
        int int_limit=Integer.valueOf(limit);
        List<Map<String,String>> list=null;

        try {
            list=dao.queryChengtiComplainByBuildingId(building_id,(int_current_page-1)*int_limit,int_limit);
        } catch (Exception e) {
            logger.error("==> list=dao.queryChengtiComplainByBuildingId(building_id,(int_current_page-1)*int_limit,int_limit) execute error , building_id = {} , current_page = {} , limit = {} , error = {} ",building_id,current_page,limit,e);
            throw new WrenchException(Result.DB_ERROR_CODE,Result.DB_ERROR_MESSAGE);
        }
        int total =-1;
        try {
            total=dao.queryChengtiComplainByBuildingIdCount(building_id);
        } catch (Exception e) {
            logger.error("==> total=dao.queryChengtiComplainByBuildingIdCount(building_id) execute error , building_id = {} , error = {} ",building_id,e);
            throw new WrenchException(Result.DB_ERROR_CODE,Result.DB_ERROR_MESSAGE);
        }

        Page page=new Page();
        page.setCurrent_page(int_current_page);
        page.setLimit(int_limit);
        page.setList(list);
        page.setTotal(total);
        return page;
    }

    public Page queryChengtiComplainByDanyuanId(String danyuan_id, String current_page, String limit) throws WrenchException {
        if (WrenchUtil.hasNull(danyuan_id,current_page, limit)) {
            logger.error("==> param is not found , danyuan_id = {} , current_page = {} , limit = {} ",
                    danyuan_id,
                    current_page,
                    limit);
            throw new WrenchException(Result.PARAM_IS_NOT_FOUND_CODE, Result.PARAM_IS_NOT_FOUND_MESSAGE);
        }

        if (!WrenchUtil.areInt(current_page, limit)) {
            logger.error("==> string is not int type , current_apge = {} , limit = {} ", current_page, limit);
            throw new WrenchException(Result.STRING_IS_NOT_INT_TYPE_MESSAGE, Result.STRING_IS_NOT_INT_TYPE_MESSAGE);
        }
        int int_current_page=Integer.valueOf(current_page);
        int int_limit=Integer.valueOf(limit);
        List<Map<String,String>> list=null;

        try {
            list=dao.queryChengtiComplainByDanyuanId(danyuan_id,(int_current_page-1)*int_limit,int_limit);
        } catch (Exception e) {
            logger.error("==> list=dao.queryChengtiComplainByDanyuanId(danyuan_id,(int_current_page-1)*int_limit,int_limit) execute error , danyuan_id= {} , current_page = {} , limit = {} , error = {} ",danyuan_id,current_page,limit,e);
            throw new WrenchException(Result.DB_ERROR_CODE,Result.DB_ERROR_MESSAGE);
        }
        int total =-1;
        try {
            total=dao.queryChengtiComplainByDanyuanIdCount(danyuan_id);
        } catch (Exception e) {
            logger.error("==>  total=dao.queryChengtiComplainByDanyuanIdCount(danyuan_id) execute error , danyuan_id = {} , wuye_id = {} , error = {} ",danyuan_id,e);
            throw new WrenchException(Result.DB_ERROR_CODE,Result.DB_ERROR_MESSAGE);
        }

        Page page=new Page();
        page.setCurrent_page(int_current_page);
        page.setLimit(int_limit);
        page.setList(list);
        page.setTotal(total);
        return page;
    }


    public void dealComplain(String status, String chengti_id) throws WrenchException {
        if (WrenchUtil.hasNull(status, chengti_id)) {
            logger.error("==> param is not found , status = {} , chengti_id = {} ", status, chengti_id);
            throw new WrenchException(Result.PARAM_IS_NOT_FOUND_CODE, Result.PARAM_IS_NOT_FOUND_MESSAGE);
        }
        int commit = -1;
        try {
            commit = dao.dealComplain(status, chengti_id);
        }catch(Exception e){
            logger.error("==>  commit = dao.dealComplain(status, chengti_id) execute error , status = {} , chengti_id = {} , error = {} ", status, chengti_id, e);
            throw new WrenchException(Result.DB_ERROR_CODE, Result.DB_ERROR_MESSAGE);
        }


    }





    public Page queryChengtiComplainByTel(String tel,String wuye_id,String current_page,String limit) throws WrenchException {
        if (WrenchUtil.hasNull(tel, wuye_id,current_page, limit)) {
            logger.error("==> param is not found , tel = {} , wuye_id = {} , current_page = {} , limit = {} ",
                    tel,
                    wuye_id,
                    current_page,
                    limit);
            throw new WrenchException(Result.PARAM_IS_NOT_FOUND_CODE, Result.PARAM_IS_NOT_FOUND_MESSAGE);
        }

        if (!WrenchUtil.areInt(current_page, limit)) {
            logger.error("==> string is not int type , current_apge = {} , limit = {} ", current_page, limit);
            throw new WrenchException(Result.STRING_IS_NOT_INT_TYPE_MESSAGE, Result.STRING_IS_NOT_INT_TYPE_MESSAGE);
        }
        int int_current_page=Integer.valueOf(current_page);
        int int_limit=Integer.valueOf(limit);
        List<Map<String,String>> list=null;

        try {
            list=dao.queryChengtiComplainByTel(tel,wuye_id,(int_current_page-1)*int_limit,int_limit);
        } catch (Exception e) {
            logger.error("==> list=dao.queryChengtiComplainByTel(tel,wuye_id,(int_current_page-1)*int_limit,int_limit) execute error , tel = {} , wuye_id = {} , current_page = {} , limit = {} , error = {} ",tel,wuye_id,current_page,limit,e);
            throw new WrenchException(Result.DB_ERROR_CODE,Result.DB_ERROR_MESSAGE);
        }
        int total =-1;
        try {
            total=dao.queryChengtiComplainByTelCount(tel,wuye_id);
        } catch (Exception e) {
            logger.error("==> total=dao.queryChengtiComplainByTel(tel,wuye_id) execute error , tel = {} , wuye_id = {} , error = {} ",tel,wuye_id,e);
            throw new WrenchException(Result.DB_ERROR_CODE,Result.DB_ERROR_MESSAGE);
        }

        Page page=new Page();
        page.setCurrent_page(int_current_page);
        page.setLimit(int_limit);
        page.setList(list);
        page.setTotal(total);
        return page;

    }
}
